<extend name="Index/index" />
<block name="center">
<div class="panel panel-blue">
 	<div class="col-lg-12" style="padding-left:0px;padding-right:0px;">
        <div class="panel panel-pink" style="height:500px;">
    		<div class="panel-heading">添加优惠</div>
            <div class="panel-body pan" style="margin-top:10px;">


                <form class="form-horizontal form-bordered dashed" action="{:U('Admin/Sell/insert')}" method="post">
                    <div class="form-body" style="margin-top:100px;">
                        <div class="form-group">
                            <label class="col-md-3 control-label" for="selCountry">选择产品</label>
                            <div class="col-md-4">
                                <select class="form-control" id="selCountry" name="fid">
									<foreach name="finfo" item="vo" key="k">  
                                    <option value="{$vo['id']}">{$vo['name']}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>
						<div class="form-group">
                            <label class="col-md-3 control-label" for="inputFirstName">优惠时间</label>
                            <div class="col-md-4">
                                <div style="float:left;"><input type="text" class="form-control" placeholder="请输入优惠的天数" id="selltime" name="selltime" ></div><div style="float:left;margin-top:10px;" error="请输入数字" id="dayerror"></div>
                            </div>
							
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label" for="inputFirstName" >优惠价格</label>
                            <div class="col-md-4">
                                <div style="float:left;"><input type="text" class="form-control" placeholder="请输入优惠的价格" id="sellprice" name="sprice" ></div><div style="float:left;margin-top:10px;" error="请输入数字" id="priceerror"></div>
                            </div>
                        </div>
                    </div>
                    <div class="form-actions text-right pal" >
                        <button class="btn btn-primary" style="margin-right:800px;">添加</button>&nbsp;
                    </div>
                </form>


            </div>
        </div>
    </div>   
</div>
<script type="text/javascript" src="__PUBLIC__/js/jquery-1.8.3.min.js"></script>

<script type="text/javascript">

$(function(){
	var statu = false;
	$('#selltime').blur(function(){
		//获取值
		var v = $(this).val();
		// alert(v);
		var reg = /^\d+$/;
		var res = reg.test(v);
		// alert(res);
		var error = $('#dayerror').attr('error');
		// alert(error);
		// alert(v);
		if(!res){
			$(this).css('border','1px solid red');
			$('#dayerror').html(error).css('color','red');

			statu = false;
		}else{
			$(this).css('border','1px solid green');
			$('#dayerror').html('√').css('color','green');
			
			statu = true;
		}
	})
	$('#sellprice').blur(function(){
		//获取值
		var v = $(this).val();
		// alert(v);
		var reg = /^\d+$/;
		var res = reg.test(v);
		// alert(res);
		var error = $('#priceerror').attr('error');
		// alert(error);
		// alert(v);
		if(!res){
			$(this).css('border','1px solid red');
			$('#priceerror').html(error).css('color','red');

			statu = false;
		}else{
			$(this).css('border','1px solid green');
			$('#priceerror').html('√').css('color','green');

			statu = true;
		}
	})

	$('form').submit(function(){
			//脚本中触发丧失焦点事件
			$('#sellprice').trigger('blur');
			$('#selltime').trigger('blur');
			if(statu){
				return true;
			}

			//阻止默认行为
			return false;
		})


})

</script>
</block> 
